**************************************************************************
* Panel Regressions showing differences between democracy & dictatorship *
**************************************************************************
use Thomson_Ch3_Data.dta
set more off
set scheme s2mono



*****************************
* Hausman test for FE vs RE *
*****************************
* Null hypothesis is, no regressors are correlated with the unobservable panel-level effect, and the RE estimator is consistent & efficient, FE is just consistent

xtreg nra_tott dict2 iplandgini urban inequality_1 lngdp arableland_pc agland aggdp, fe
est store fe

xtreg nra_tott dict2 iplandgini urban inequality_1 lngdp arableland_pc agland
est store re

hausman fe re, sigmamore
* Rejects null hypothesis, RE is inconsistent



***********************
* Summary Stats Table *
***********************
xtreg nra_tott dict2 urban urban_dict2 iplandgini inequality_dict2 landgini_dict2 inequality_1 lngdp arableland_pc agland foodindex aggdp ///
seventies eighties nineties noughties, fe vce(cluster cnum)

* Table of summary stats for all variables *
sutex nra_tott dict2 polity2 autocracy anocracy democracy dictatorship gwf_military gwf_personal gwf_party ///
iplandgini urban inequality_1 lngdp aggdp foodindex ///
if e(sample), digits(2) ///
file ("Ch3_Var_Stats.tex") ///
labels minmax title("Summary Statistics, Policy Analysis") key(tab:ch3_varstats) replace




***************
* Regime Type *
***************
xtreg nra_tott dict2 lngdp arableland_pc agland foodindex aggdp ///
seventies eighties nineties noughties, fe vce(cluster cnum)
est store regime_2

* CGV Measure
xtreg nra_tott dictatorship lngdp arableland_pc agland foodindex aggdp ///
seventies eighties nineties noughties, fe vce(cluster cnum)


xtreg nra_tott dem_dummy lngdp arableland_pc agland foodindex aggdp ///
seventies eighties nineties noughties, fe vce(cluster cnum)
margins, at(dem_dummy=(0 1))
marginsplot, recast(scatter) yline(0, lwidth(vthin)) graphregion(color(white)) xsize(6) ysize(6) ///
title("Dict (Polity)") ytitle("NRA") xtitle("") legend(off)
graph save regime_2, replace

xtreg nra_tott polity2 lngdp arableland_pc agland foodindex aggdp ///
seventies eighties nineties noughties, fe
est store regime_3
margins, at(polity2=(-10(1)10))
marginsplot, recast(line) recastci(rline) plot1opts(lwidth(medium)) ciopts(lwidth(thin) lpattern(longdash)) ///
addplot(kdensity polity2 if e(sample), yaxis(2)) yline(0, lwidth(vthin)) graphregion(color(white)) bgcolor(white) xsize(6) ysize(6) ///
title("Polity") ytitle("NRA") xtitle("Polity 2") xlabel(-10(5)10) legend(off)
graph save regime_3, replace

xtreg nra_tott anocracy democracy lngdp arableland_pc agland foodindex aggdp ///
seventies eighties nineties noughties, fe vce(cluster cnum)
est store regime_4

xtreg nra_tott i.regime lngdp arableland_pc agland foodindex aggdp ///
seventies eighties nineties noughties, fe vce(cluster cnum)
margins, at(regime=(0 1 2)) atmeans
marginsplot, recast(scatter) yline(0, lwidth(vthin)) graphregion(color(white)) xsize(6) ysize(6) ///
title("Type (Polity)") ytitle("NRA") xtitle("") legend(off)
graph save regime_4, replace

xtreg nra_tott gwf_party gwf_military lngdp arableland_pc agland foodindex aggdp ///
seventies eighties nineties noughties if gwf_nonautocracy=="NA", fe vce(cluster cnum)
est store regime_5

xtreg nra_tott i.gwf_regime lngdp arableland_pc agland foodindex aggdp ///
seventies eighties nineties noughties if gwf_nonautocracy=="NA", fe vce(cluster cnum)
margins, at(gwf_regime=(0 1 2))
marginsplot, recast(scatter) yline(0, lwidth(vthin)) graphregion(color(white)) xsize(6) ysize(6) ///
title("Type (Geddes)") ytitle("NRA") xtitle("") legend(off) scheme(s2mono)
graph save regime_5, replace


* Regional Analysis
xtreg nra_tott polity2 lngdp aggdp arableland_pc agland foodindex seventies eighties nineties noughties if region=="AFRICA"
est store polity_africa
margins, at(polity2=(-10(1)10))
marginsplot, recast(line) recastci(rline) plot1opts(lwidth(medium)) ciopts(lwidth(thin) lpattern(longdash)) ///
addplot(kdensity polity2 if e(sample), yaxis(2)) yline(0, lwidth(vthin)) graphregion(color(white)) xsize(6) ysize(6) ///
title("Africa") ytitle("NRA") xtitle("Polity 2") xlabel(-10(5)10) legend(off)
graph save polity_africa, replace

xtreg nra_tott polity2 lngdp aggdp arableland_pc agland foodindex seventies eighties nineties noughties if region=="ASIA (excl. Japan)"
est store polity_asia
margins, at(polity2=(-10(1)10))
marginsplot, recast(line) recastci(rline) plot1opts(lwidth(medium)) ciopts(lwidth(thin) lpattern(longdash)) ///
addplot(kdensity polity2 if e(sample), yaxis(2)) yline(0, lwidth(vthin)) graphregion(color(white)) xsize(6) ysize(6) ///
title("Asia") ytitle("NRA") xtitle("Polity 2") xlabel(-10(5)10) legend(off)
graph save polity_asia, replace

xtreg nra_tott polity2 lngdp aggdp arableland_pc agland foodindex seventies eighties nineties noughties if region=="LAC"
est store polity_lac
margins, at(polity2=(-10(1)10))
marginsplot, recast(line) recastci(rline) plot1opts(lwidth(medium)) ciopts(lwidth(thin) lpattern(longdash)) ///
addplot(kdensity polity2 if e(sample), yaxis(2)) yline(0, lwidth(vthin)) graphregion(color(white)) xsize(6) ysize(6) ///
title("L America") ytitle("NRA") xtitle("Polity 2") xlabel(-10(5)10) legend(off)
graph save polity_lac, replace

xtreg nra_tott polity2 lngdp aggdp arableland_pc agland foodindex seventies eighties nineties noughties if region=="HIC"
est store polity_hic
margins, at(polity2=(-10(1)10))
marginsplot, recast(line) recastci(rline) plot1opts(lwidth(medium)) ciopts(lwidth(thin) lpattern(longdash)) ///
addplot(kdensity polity2 if e(sample), yaxis(2)) graphregion(color(white)) xsize(6) ysize(6) ///
title("High Inc") ytitle("NRA") xtitle("Polity 2") xlabel(-10(5)10) legend(off)
graph save polity_hic, replace

esttab regime_2 regime_3 regime_4 regime_5 polity_africa polity_asia polity_lac polity_hic using Regime_Type_Results.tex, ///
keep(dict2 polity2 democracy anocracy gwf_party gwf_military lngdp foodindex aggdp) ///
order(dict2 polity2 democracy anocracy gwf_party gwf_military lngdp foodindex aggdp) ///
replace b(2) se scalars("N_g Countries") sfmt(%12.0f) label nonumbers ///
mtitle("(1.1) Dict" "(1.2) Polity" "(1.3) Type" "(1.4) Type" "(1.5) Africa" "(1.6) Asia" "(1.7) LA" "(1.8) HIC") ///
compress nogaps addnotes("Models 1-5 with country fixed effects" "All models include Arable land, Ag land, Decade dummies")

esttab regime_2 regime_3 regime_4 regime_5 polity_africa polity_asia polity_lac polity_hic, ///
keep(dict2 polity2 democracy anocracy gwf_party gwf_military lngdp foodindex aggdp) ///
order(dict2 polity2 democracy anocracy gwf_party gwf_military lngdp foodindex aggdp) ///
b(3) se scalars("N_g Countries") sfmt(%12.0f) label nonumbers ///
mtitle("(1.1) Dict" "(1.2) Polity" "(1.3) Type" "(1.4) Type" "(1.5) Africa" "(1.6) Asia" "(1.7) LA" "(1.8) HIC") ///
compress nogaps addnotes("Models 1-5 with country fixed effects" "All models include Arable land, Ag land, Decade dummies")

graph combine polity_africa.gph polity_asia.gph polity_lac.gph polity_hic.gph, graphregion(color(white)) xcommon
*graph export Polity_Regions.pdf, replace

graph combine regime_2.gph regime_3.gph regime_4.gph regime_5.gph, graphregion(color(white)) ycommon




*****************
* All Interests *
*****************
*NRA
xtreg nra_tott dict2 urban urban_dict2 iplandgini inequality_dict2 landgini_dict2 inequality_1 lngdp arableland_pc agland foodindex aggdp ///
seventies eighties nineties noughties, fe vce(cluster cnum)
est store nra_1

* CGV Measure
xtreg nra_tott dictatorship urban urban_dictatorship iplandgini landgini_dictatorship inequality_1 inequality_dictatorship lngdp arableland_pc agland foodindex aggdp ///
seventies eighties nineties noughties, fe vce(cluster cnum)
est store nra_1_cgv

*RRA
xtreg rra dict2 urban urban_dict2 iplandgini inequality_dict2 landgini_dict2 inequality_1 lngdp arableland_pc agland foodindex aggdp ///
seventies eighties nineties noughties, fe vce(cluster cnum)
est store rra_1

*CGV Measure
xtreg rra dictatorship urban urban_dictatorship iplandgini landgini_dictatorship inequality_1 inequality_dictatorship lngdp arableland_pc agland foodindex aggdp ///
seventies eighties nineties noughties, fe vce(cluster cnum)
est store rra_1_cgv

*CTE
xtreg cte_covt dict2 urban urban_dict2 iplandgini inequality_dict2 landgini_dict2 inequality_1 lngdp arableland_pc agland foodindex aggdp ///
seventies eighties nineties noughties, fe vce(cluster cnum)
est store cte_1

*CGV Measure
xtreg cte_covt dictatorship urban urban_dictatorship iplandgini landgini_dictatorship inequality_1 inequality_dictatorship lngdp arableland_pc agland foodindex aggdp ///
seventies eighties nineties noughties, fe vce(cluster cnum)
est store cte_1_cgv

* Autocracies only
xtreg nra_tott urban iplandgini inequality_1 gwf_party gwf_military lngdp arableland_pc agland foodindex aggdp ///
seventies eighties nineties noughties if gwf_nonautocracy=="NA", fe vce(cluster cnum)
est store autocracies

* NRA
xtreg nra_tott dict2 urban urban_dict2 iplandgini inequality_dict2 landgini_dict2 inequality_1 lngdp arableland_pc agland foodindex aggdp ///
seventies eighties nineties noughties reg1-reg4, re
est store nra_2

* CGV Measure
xtreg nra_tott dictatorship urban urban_dictatorship iplandgini landgini_dictatorship inequality_1 inequality_dictatorship lngdp arableland_pc agland foodindex aggdp ///
seventies eighties nineties noughties reg1-reg4, re
est store nra_2_cgv

*NRA
xtreg nra_tott dict2 urban urban_dict2 landgini_ipolated ip_junker inequality_1 inequality_dict2  lngdp arableland_pc agland foodindex aggdp ///
seventies eighties nineties noughties, fe vce(cluster cnum)
est store nra_3

* CGV Measure
xtreg nra_tott dictatorship urban urban_dictatorship iplandgini landgini_dictatorship inequality_1 inequality_dictatorship lngdp arableland_pc agland foodindex aggdp ///
seventies eighties nineties noughties, fe vce(cluster cnum)
est store nra_3_cgv

esttab nra_1 nra_2 nra_3 rra_1 cte_1 autocracies, ///
keep(dict2 urban urban_dict2 iplandgini landgini_dict2 landgini_ipolated ip_junker inequality_1 inequality_dict2 gwf_military gwf_party lngdp) ///
order(dict2 urban urban_dict2 iplandgini landgini_dict2 landgini_ipolated ip_junker inequality_1 inequality_dict2 gwf_military gwf_party lngdp) ///
b(2) se aic scalars("N_g Countries") sfmt(%12.0f) label nonumbers ///
mtitle("(2.1)" "(2.2)" "(2.3)" "(2.4) RRA" "(2.5) CTE" "(2.6) Dict") ///
compress nogaps addnotes("All models except 2.2 with country fixed effects" "All models include Arable land, Ag land, Food Index, Ag/GDP, Decade dummies")

esttab nra_1 nra_2 nra_3 rra_1 cte_1 autocracies using Ch3_Main_Results.tex, ///
keep(dict2 urban urban_dict2 iplandgini landgini_dict2 landgini_ipolated ip_junker inequality_1 inequality_dict2 gwf_military gwf_party lngdp) ///
order(dict2 urban urban_dict2 iplandgini landgini_dict2 landgini_ipolated ip_junker inequality_1 inequality_dict2 gwf_military gwf_party lngdp) ///
b(2) se aic scalars("N_g Countries") sfmt(%12.0f) label nonumbers ///
replace mtitle("(2.1)" "(2.2)" "(2.3)" "(2.4) RRA" "(2.5) CTE" "(2.6) Dict") ///
compress nogaps addnotes("All models except 2.2 with country fixed effects, 2.2 includes five region dummies" "All models include Arable land, Ag land, Food Index, Ag/GDP, Decade dummies")

esttab nra_1_cgv nra_2_cgv nra_3_cgv rra_1_cgv cte_1_cgv, ///
keep(dictatorship urban urban_dictatorship iplandgini landgini_dictatorship inequality_1 inequality_dictatorship lngdp) ///
order(dictatorship urban urban_dictatorship iplandgini landgini_dictatorship inequality_1 inequality_dictatorship lngdp) ///
b(2) se aic scalars("N_g Countries") sfmt(%12.0f) label nonumbers ///
mtitle("NRA" "NRA" "NRA" "RRA" "CTE" "Dict") ///
compress nogaps addnotes("All models with country fixed effects" "All models include Arable land, Ag land, Food Index, Ag/GDP, Decade dummies")

esttab nra_1_cgv nra_2_cgv nra_3_cgv rra_1_cgv cte_1_cgv using Ch3_Main_Results_CGV.tex, ///
keep(dictatorship urban urban_dictatorship iplandgini landgini_dictatorship inequality_1 inequality_dictatorship lngdp) ///
order(dictatorship urban urban_dictatorship iplandgini landgini_dictatorship inequality_1 inequality_dictatorship lngdp) ///
b(2) se aic scalars("N_g Countries") sfmt(%12.0f) label nonumbers replace ///
mtitle("NRA" "NRA" "NRA" "RRA" "CTE" "Dict") ///
compress nogaps addnotes("All models with country fixed effects" "All models include Arable land, Ag land, Food Index, Ag/GDP, Decade dummies")




*******************
* Urban Interests *
*******************
* Urbanization
* Model 3.1
xtreg nra_tott dict2 urban lngdp arableland_pc agland foodindex aggdp ///
seventies eighties nineties noughties, fe vce(cluster cnum)
est store urban_1

*Model 3.2
xtreg nra_tott dict2 urban urban_dict2 lngdp arableland_pc agland foodindex aggdp ///
seventies eighties nineties noughties, fe vce(cluster cnum)
est store urban_2

xtreg nra_tott i.dict2##c.urban lngdp arableland_pc agland foodindex aggdp ///
seventies eighties nineties noughties, fe vce(cluster cnum)
margins, at(urban=(0.05(0.1)0.95) dict2=(0 1)) atmeans

*Model 2.1
xtreg nra_tott dict2 urban urban_dict2 iplandgini inequality_dict2 landgini_dict2 inequality_1 lngdp arableland_pc agland foodindex aggdp ///
seventies eighties nineties noughties, fe vce(cluster cnum)
est store urban_3

xtreg nra_tott i.dict2##c.urban i.dict2##c.iplandgini i.dict2##c.inequality_1 lngdp arableland_pc agland foodindex aggdp ///
seventies eighties nineties noughties, fe vce(cluster cnum)
margins, dydx(dict2) at(urban=(0.05(0.1)0.95)) atmeans
marginsplot, recastci(rline) plot1opts(lcolor(black) lwidth(medium)) ci1opts(lwidth(thin) lcolor(black) lpattern(longdash))  ///
title("MEs of Regime by Urban, 95% CIs") ytitle("Marginal Effect") xlabel(0.05(0.1)0.95) ///
addplot(kdensity urban if urban>0.049 & urban<0.951 & e(sample), lpattern(shortdash) lwidth(thin) yaxis(2)) xsize(5) ysize(6) xlabel(0.05(0.15)0.95) ///
yline(0, lwidth(vthin)) legend(pos(6) cols(3) size(small)) scheme(s2mono) graphregion(fcolor(white))
graph save urban_mes, replace

margins dict2, at(urban=(0.05(0.05)0.95)) atmeans
marginsplot, recastci(rline) plot1opts(lcolor(black) lwidth(medium)) ci1opts(lwidth(thin) lcolor(black) lpattern(longdash))  ///
plot2opts(lcolor(gs5) lwidth(medium)) ci2opts(lwidth(thin) lcolor(gs5) lpattern(longdash)) ///
addplot(kdensity urban if urban>0.049 & urban<0.951 & e(sample), lpattern(shortdash) lwidth(thin) yaxis(2)) xsize(5) ysize(6) xlabel(0.05(0.15)0.95) ///
yline(0, lwidth(vthin)) legend(pos(6) cols(3) size(small)) scheme(s2mono) graphregion(fcolor(white)) ///
title("Support by Urban & Regime, 95% CIs") ytitle("Predicted NRA") xtitle("Urban")
graph save urban_regime, replace

* Model 2.4 - With authoritarian regime type
xtreg nra_tott urban iplandgini inequality_1 gwf_party gwf_military lngdp arableland_pc agland foodindex aggdp ///
seventies eighties nineties noughties if gwf_nonautocracy=="NA", fe vce(cluster cnum)
est store urban_4

graph combine urban_regime.gph urban_mes.gph, xcommon graphregion(fcolor(white))

** Regional Analysis of Urbanization
*Africa
xtreg nra_tott dict2 urban urban_dict2 iplandgini inequality_1 lngdp aggdp arableland_pc agland foodindex seventies eighties nineties noughties if region=="AFRICA"
est store urban_int_africa
	
xtreg nra_tott i.dict2##c.urban iplandgini inequality_1 lngdp aggdp arableland_pc agland foodindex seventies eighties nineties noughties if region=="AFRICA"
margins, at(urban=(0.05(0.05)0.6) dict2=(0 1))
marginsplot, recastci(rline) plot1opts(lcolor(black) lwidth(medthin)) ci1opts(lwidth(thin) lcolor(black) lpattern(longdash))  ///
plot2opts(lcolor(gs5)) ci2opts(lwidth(thin) lcolor(gs5) lpattern(longdash)) xlabel(0.05(0.15)0.95) ///
addplot(kdensity urban if e(sample), yaxis(2) lwidth(vthin)) yline(0, lwidth(vthin)) graphregion(color(white)) xsize(5) ysize(6) ///
title("Africa") ytitle("NRA") xtitle("Urban")
graph save urban_int_africa, replace

*Asia
xtreg nra_tott dict2 urban urban_dict2 iplandgini inequality_1 lngdp aggdp arableland_pc agland foodindex seventies eighties nineties noughties if region=="ASIA (excl. Japan)"
est store urban_int_asia

xtreg nra_tott i.dict2##c.urban lngdp aggdp arableland_pc agland foodindex seventies eighties nineties noughties if region=="ASIA (excl. Japan)"
margins, at(urban=(0.05(0.05)0.8) dict2=(0 1))
marginsplot, recastci(rline) plot1opts(lcolor(black) lwidth(medthin)) ci1opts(lwidth(thin) lcolor(black) lpattern(longdash))  ///
plot2opts(lcolor(gs5)) ci2opts(lwidth(thin) lcolor(gs5) lpattern(longdash)) xlabel(0.05(0.15)0.95) ///
addplot(kdensity urban if e(sample), yaxis(2) lwidth(vthin)) yline(0, lwidth(vthin)) graphregion(color(white)) xsize(5) ysize(6) ///
title("Asia") ytitle("NRA") xtitle("Urban")
graph save urban_int_asia, replace

*Latin America
xtreg nra_tott dict2 urban urban_dict2 iplandgini inequality_1 lngdp aggdp arableland_pc agland foodindex seventies eighties nineties noughties if region=="LAC"
est store urban_int_lac

xtreg nra_tott i.dict2##c.urban iplandgini inequality_1 lngdp aggdp arableland_pc agland foodindex seventies eighties nineties noughties if region=="LAC"
margins, at(urban=(0.3(0.05)0.9) dict2=(0 1))
marginsplot, recastci(rline) plot1opts(lcolor(black) lwidth(medthin)) ci1opts(lwidth(thin) lcolor(black) lpattern(longdash))  ///
plot2opts(lcolor(gs5)) ci2opts(lwidth(thin) lcolor(gs5) lpattern(longdash)) xlabel(0.05(0.15)0.95) ///
addplot(kdensity urban if e(sample), yaxis(2) lwidth(vthin)) yline(0, lwidth(vthin)) graphregion(color(white)) xsize(5) ysize(6) ///
title("L America") ytitle("NRA") xtitle("Urban")
graph save urban_int_lac, replace

*High Income
xtreg nra_tott dict2 urban urban_dict2 iplandgini inequality_1 lngdp aggdp arableland_pc agland foodindex seventies eighties nineties noughties if region=="HIC"
est store urban_int_hic

xtreg nra_tott i.dict2##c.urban iplandgini inequality_1 lngdp aggdp arableland_pc agland foodindex seventies eighties nineties noughties if region=="HIC"
margins, at(urban=(0.25(0.05)0.95) dict2=(0 1))
marginsplot, recastci(rline) plot1opts(lcolor(black) lwidth(medthin)) ci1opts(lwidth(thin) lcolor(black) lpattern(longdash))  ///
plot2opts(lcolor(gs5)) ci2opts(lwidth(thin) lcolor(gs5) lpattern(longdash)) xlabel(0.05(0.15)0.95) ///
addplot(kdensity urban if e(sample), yaxis(2) lwidth(vthin)) yline(0, lwidth(vthin)) graphregion(color(white)) xsize(5) ysize(6) ///
title("High Inc") ytitle("NRA") xtitle("Urban")
graph save urban_int_hic, replace

esttab urban_1 urban_2 urban_int_africa urban_int_asia urban_int_lac urban_int_hic using Urbanization_Results.tex, ///
keep(urban dict2 urban_dict2 iplandgini inequality_1 lngdp aggdp foodindex) ///
order(urban dict2 urban_dict2 iplandgini inequality_1 lngdp aggdp foodindex) ///
replace b(2) se scalars("N_g Countries") sfmt(%12.0f) label nonumbers ///
mtitle("(3.1)" "(3.2)" "(3.3) Africa" "(3.4) Asia" "(3.5) LA" "(3.6) HIC") ///
compress nogaps addnotes("Models 3.1, 3.2 with country fixed effects" "All models include Arable land, Ag land, Food Index, Ag/GDP, Decade dummies")

esttab urban_1 urban_2 urban_int_africa urban_int_asia urban_int_lac urban_int_hic, ///
keep(urban dict2 urban_dict2 iplandgini inequality_1 lngdp aggdp foodindex) ///
order(urban dict2 urban_dict2 iplandgini inequality_1 lngdp aggdp foodindex) ///
b(2) se scalars("N_g Countries") sfmt(%12.0f) label nonumbers ///
mtitle("(3.1)" "(3.2)" "(3.3) Africa" "(3.4) Asia" "(3.5) LA" "(3.6) HIC") ///
compress nogaps addnotes("Models 3.1, 3.2 with country fixed effects" "All models include Arable land, Ag land, Food Index, Ag/GDP, Decade dummies")

*grc1leg urban_int_africa.gph urban_int_asia.gph urban_int_lac.gph urban_int_hic.gph, graphregion(color(white))

*graph combine urban_africa.gph urban_asia.gph urban_lac.gph urban_hic.gph, graphregion(color(white))



* Inequality
* Model 4.1
xtreg nra_tott dict2 inequality_1 lngdp arableland_pc agland foodindex aggdp ///
seventies eighties nineties noughties, fe
est store ineq_1
margins, at(inequality_1=(0.25(0.025)0.60))

*Model 4.2
xtreg nra_tott dict2 inequality_1 inequality_dict2 lngdp arableland_pc agland foodindex aggdp ///
seventies eighties nineties noughties, fe vce(cluster cnum)
est store ineq_2

xtreg nra_tott i.dict2##c.inequality_1 lngdp arableland_pc agland foodindex aggdp ///
seventies eighties nineties noughties, fe vce(cluster cnum)
margins, at(inequality_1=(0.05(0.1)0.60) dict2=(0 1)) atmeans

*Model 2.3 (same as in previous table)
xtreg nra_tott i.dict2##c.urban i.dict2##c.iplandgini i.dict2##c.inequality_1 lngdp arableland_pc agland foodindex aggdp ///
seventies eighties nineties noughties, fe vce(cluster cnum)
margins, dydx(dict2) at(inequality_1=(0.25(0.025)0.60)) atmeans
marginsplot, recastci(rline) plot1opts(lcolor(black) lwidth(medium)) ci1opts(lwidth(thin) lcolor(black) lpattern(longdash))  ///
title("MEs of Regime by Inequality, 95% CIs") ytitle("Marginal Effect") xlabel(0.25(0.05)0.60) ///
addplot(kdensity inequality_1 if inequality_1>0.249 & inequality_1<0.601 & e(sample), lpattern(shortdash) lwidth(thin) yaxis(2)) xsize(5) ysize(6) xlabel(0.05(0.15)0.95) ///
yline(0, lwidth(vthin)) legend(pos(6) cols(3) size(small)) scheme(s2mono) graphregion(fcolor(white))
graph save ineq_mes, replace

margins dict2, at(inequality_1=(0.25(0.025)0.60)) atmeans
marginsplot, recastci(rline) plot1opts(lcolor(black) lwidth(medium)) ci1opts(lwidth(thin) lcolor(black) lpattern(longdash))  ///
plot2opts(lcolor(gs5) lwidth(medium)) ci2opts(lwidth(thin) lcolor(gs5) lpattern(longdash)) ///
addplot(kdensity inequality_1 if inequality_1>0.249 & inequality_1<0.601 & e(sample), lpattern(shortdash) lwidth(thin) yaxis(2)) xsize(5) ysize(6) xlabel(0.05(0.15)0.95) ///
yline(0, lwidth(vthin)) legend(pos(6) cols(3) size(small)) scheme(s2mono) graphregion(fcolor(white)) ///
title("Support by Inequality & Regime, 95% CIs") ytitle("Predicted NRA") xtitle("Inequality") xlabel(0.25(0.05)0.60)
graph save ineq_regime, replace

graph combine ineq_regime.gph ineq_mes.gph, xcommon graphregion(color(white))

*Regional analysis of inequality
* Africa
xtreg nra_tott dict2 inequality_1 inequality_dict2 iplandgini urban lngdp arableland_pc agland foodindex aggdp ///
seventies eighties nineties noughties if region=="AFRICA"
est store ineq_int_africa

xtreg nra_tott i.dict2##c.ipineq iplandgini urban lngdp aggdp arableland_pc agland foodindex ///
seventies eighties nineties noughties if region=="AFRICA"
margins, at(ipineq=(0.325(0.025)0.575) dict2=(0 1))
marginsplot, recastci(rline) plot1opts(lcolor(black) lwidth(medthin)) ci1opts(lwidth(thin) lcolor(black) lpattern(longdash))  ///
plot2opts(lcolor(gs5)) ci2opts(lwidth(thin) lcolor(gs5) lpattern(longdash)) ///
addplot(kdensity ipineq if e(sample), yaxis(2) lwidth(vthin)) yline(0, lwidth(vthin)) graphregion(color(white)) xsize(5) ysize(6) ///
title("Africa") ytitle("NRA") xtitle("Inequality")
graph save ineq_int_africa, replace

*Asia
xtreg nra_tott dict2 inequality_1 inequality_dict2 iplandgini urban lngdp arableland_pc agland foodindex aggdp ///
seventies eighties nineties noughties if region=="ASIA (excl. Japan)"
est store ineq_int_asia

xtreg nra_tott i.dict2##c.ipineq iplandgini urban lngdp aggdp arableland_pc agland foodindex ///
seventies eighties nineties noughties if region=="ASIA (excl. Japan)"
margins, at(ipineq=(0.275(0.025)0.525) dict2=(0 1))
marginsplot, recastci(rline) plot1opts(lcolor(black) lwidth(medthin)) ci1opts(lwidth(thin) lcolor(black) lpattern(longdash))  ///
plot2opts(lcolor(gs5)) ci2opts(lwidth(thin) lcolor(gs5) lpattern(longdash)) ///
addplot(kdensity ipineq if e(sample), yaxis(2) lwidth(vthin)) yline(0, lwidth(vthin)) graphregion(color(white)) xsize(5) ysize(6) ///
title("Asia") ytitle("NRA") xtitle("Inequality")
graph save ineq_int_asia, replace

*Latin America
xtreg nra_tott dict2 inequality_1 inequality_dict2 iplandgini urban lngdp arableland_pc agland foodindex aggdp ///
seventies eighties nineties noughties if region=="LAC"
est store ineq_int_lac

xtreg nra_tott i.dict2##c.ipineq iplandgini urban lngdp aggdp arableland_pc agland foodindex ///
seventies eighties nineties noughties if region=="LAC"
margins, at(ipineq=(0.375(0.025)0.5) dict2=(0 1))
marginsplot, recastci(rline) plot1opts(lcolor(black) lwidth(medthin)) ci1opts(lwidth(thin) lcolor(black) lpattern(longdash))  ///
plot2opts(lcolor(gs5)) ci2opts(lwidth(thin) lcolor(gs5) lpattern(longdash)) ///
addplot(kdensity ipineq if e(sample), yaxis(2) lwidth(vthin)) yline(0, lwidth(vthin)) graphregion(color(white)) xsize(5) ysize(6) ///
title("L America") ytitle("NRA") xtitle("Inequality")
graph save ineq_int_lac, replace

*High Income Countries
xtreg nra_tott dict2 inequality_1 inequality_dict2 iplandgini urban lngdp arableland_pc agland foodindex aggdp ///
seventies eighties nineties noughties if region=="HIC"
est store ineq_int_hic

xtreg nra_tott i.dict2##c.ipineq iplandgini urban lngdp aggdp arableland_pc agland foodindex ///
seventies eighties nineties noughties if region=="HIC"
margins, at(ipineq=(0.275(0.025)0.45) dict2=(0 1))
marginsplot, recastci(rline) plot1opts(lcolor(black) lwidth(medthin)) ci1opts(lwidth(thin) lcolor(black) lpattern(longdash))  ///
plot2opts(lcolor(gs5)) ci2opts(lwidth(thin) lcolor(gs5) lpattern(longdash)) ///
addplot(kdensity ipineq if e(sample), yaxis(2) lwidth(vthin)) graphregion(color(white)) xsize(5) ysize(6) ///
title("High Inc") ytitle("NRA") xtitle("Inequality")
graph save ineq_int_hic, replace

esttab ineq_1 ineq_2 ineq_int_africa ineq_int_asia ineq_int_lac ineq_int_hic using Inequality_Results.tex, ///
keep(inequality_1 dict2 inequality_dict2 urban iplandgini lngdp aggdp foodindex) ///
order(inequality_1 dict2 inequality_dict2 urban iplandgini lngdp aggdp foodindex) ///
replace b(2) se scalars("N_g Countries") sfmt(%12.0f) label nonumbers ///
mtitle("(4.1)" "(4.2)" "(4.3) Africa" "(4.4) Asia" "(4.5) LA" "(4.6) HIC") ///
compress nogaps addnotes("Models 4.1, 4.2 with country fixed effects" "All models include Arable land, Ag land, Food Index, Ag/GDP, Decade dummies")

esttab ineq_1 ineq_2 ineq_int_africa ineq_int_asia ineq_int_lac ineq_int_hic, ///
keep(inequality_1 dict2 inequality_dict2 urban iplandgini lngdp aggdp foodindex) ///
order(inequality_1 dict2 inequality_dict2 urban iplandgini lngdp aggdp foodindex) ///
replace b(2) se aic scalars("N_g Countries") sfmt(%12.0f) label nonumbers ///
mtitle("(4.1)" "(4.2)" "(4.3) Africa" "(4.4) Asia" "(4.5) LA" "(4.6) HIC") ///
compress nogaps addnotes("Models 4.1, 4.2 with country fixed effects" "All models include Arable land, Ag land, Food Index, Ag/GDP, Decade dummies")

grc1leg ineq_int_africa.gph ineq_int_asia.gph ineq_int_lac.gph ineq_int_hic.gph



*******************
* Rural Interests *
*******************
* Model 5.1
xtreg nra_tott dict2 iplandgini lngdp arableland_pc agland foodindex aggdp ///
seventies eighties nineties noughties, fe
est store landgini_1
margins, at(iplandgini=(0.25(0.05)0.95))

*Model 5.2
xtreg nra_tott dict2 iplandgini landgini_dict2 lngdp arableland_pc agland foodindex aggdp ///
seventies eighties nineties noughties, fe vce(cluster cnum)
est store landgini_2

xtreg nra_tott i.dict2##c.iplandgini lngdp arableland_pc agland foodindex aggdp ///
seventies eighties nineties noughties, fe vce(cluster cnum)
margins, at(iplandgini=(0.25(0.05)0.95) dict2=(0 1)) atmeans

*Model 2.1
xtreg nra_tott i.dict2##c.urban i.dict2##c.iplandgini i.dict2##c.inequality_1 lngdp arableland_pc agland foodindex aggdp ///
seventies eighties nineties noughties, fe vce(cluster cnum)
margins, dydx(dict2) at(iplandgini=(0.25(0.05)0.95)) atmeans
marginsplot, recastci(rline) plot1opts(lcolor(black) lwidth(medium)) ci1opts(lwidth(thin) lcolor(black) lpattern(longdash))  ///
title("MEs of Regime by Land Gini, 95% CIs") ytitle("Marginal Effect") xlabel(0.25(0.05)0.60) ///
addplot(kdensity iplandgini if iplandgini>0.249 & iplandgini<0.951 & e(sample), lpattern(shortdash) lwidth(thin) yaxis(2)) xsize(5) ysize(6) xlabel(0.25(0.2)0.95) ///
yline(0, lwidth(vthin)) legend(pos(6) cols(3) size(small)) scheme(s2mono) graphregion(fcolor(white))
graph save landgini_mes, replace

margins dict2, at(iplandgini=(0.25(0.05)0.90)) atmeans
marginsplot, recastci(rline) plot1opts(lcolor(black) lwidth(medium)) ci1opts(lwidth(thin) lcolor(black) lpattern(longdash))  ///
plot2opts(lcolor(gs5) lwidth(medium)) ci2opts(lwidth(thin) lcolor(gs5) lpattern(longdash)) ///
addplot(kdensity iplandgini if iplandgini>0.249 & iplandgini<0.951 & e(sample), lpattern(shortdash) lwidth(thin) yaxis(2)) xsize(5) ysize(6) xlabel(0.25(0.2)0.95) ///
yline(0, lwidth(vthin)) legend(pos(6) cols(3) size(small)) scheme(s2mono) graphregion(fcolor(white)) ///
title("Support by Land Gini & Regime, 95% CIs") ytitle("Predicted NRA") xtitle("Land Gini") xlabel(0.25(0.2)0.95)
graph save landgini_regime, replace

graph combine landgini_regime.gph landgini_mes.gph, xcommon graphregion(fcolor(white))

* Regional Analysis of Land Gini
*Africa
xtreg nra_tott dict2 iplandgini landgini_dict2 inequality_1 urban lngdp aggdp arableland_pc agland foodindex ///
seventies eighties nineties noughties if region=="AFRICA"
est store landgini_int_africa

xtreg nra_tott i.dict2##c.iplandgini inequality_1 urban lngdp aggdp arableland_pc agland foodindex inequality_1 ///
seventies eighties nineties noughties if region=="AFRICA"
margins, at(iplandgini=(0.3(0.05)0.8) dict2=(0 1))
marginsplot, recastci(rline) plot1opts(lcolor(black) lwidth(medthin)) ci1opts(lwidth(thin) lcolor(black) lpattern(longdash))  ///
plot2opts(lcolor(gs5)) ci2opts(lwidth(thin) lcolor(gs5) lpattern(longdash)) ///
addplot(kdensity iplandgini if e(sample), yaxis(2) lwidth(vthin)) yline(0, lwidth(vthin)) graphregion(color(white)) xsize(5) ysize(6) ///
title("Africa") ytitle("NRA") xtitle("Land Gini") xlabel(0.3(0.1)0.8)
graph save landgini_int_africa, replace

* Asia
xtreg nra_tott dict2 iplandgini landgini_dict2 inequality_1 urban lngdp aggdp arableland_pc agland foodindex ///
seventies eighties nineties noughties if region=="ASIA (excl. Japan)"
est store landgini_int_asia

xtreg nra_tott i.dict2##c.iplandgini inequality_1 urban lngdp aggdp arableland_pc agland foodindex ///
seventies eighties nineties noughties if region=="ASIA (excl. Japan)"
margins, at(iplandgini=(0.3(0.05)0.8) dict2=(0 1))
marginsplot, recastci(rline) plot1opts(lcolor(black) lwidth(medthin)) ci1opts(lwidth(thin) lcolor(black) lpattern(longdash))  ///
plot2opts(lcolor(gs5)) ci2opts(lwidth(thin) lcolor(gs5) lpattern(longdash)) ///
addplot(kdensity iplandgini if e(sample), yaxis(2) lwidth(vthin)) yline(0, lwidth(vthin)) graphregion(color(white)) xsize(5) ysize(6) ///
title("Asia") ytitle("NRA") xtitle("Land Gini") xlabel(0.3(0.1)0.8)
graph save landgini_int_asia, replace

* Latin America
xtreg nra_tott dict2 iplandgini landgini_dict2 inequality_1 urban lngdp aggdp arableland_pc agland foodindex ///
seventies eighties nineties noughties if region=="LAC"
est store landgini_int_lac

xtreg nra_tott i.dict2##c.iplandgini inequality_1 urban lngdp aggdp arableland_pc agland foodindex inequality_1 ///
seventies eighties nineties noughties if region=="LAC"
margins, at(iplandgini=(0.6(0.025)0.9) dict2=(0 1))
marginsplot, recastci(rline) plot1opts(lcolor(black) lwidth(medthin)) ci1opts(lwidth(thin) lcolor(black) lpattern(longdash))  ///
plot2opts(lcolor(gs5)) ci2opts(lwidth(thin) lcolor(gs5) lpattern(longdash)) ///
addplot(kdensity iplandgini if e(sample) & iplandgini<0.9, yaxis(2) lwidth(vthin)) yline(0, lwidth(vthin)) graphregion(color(white)) xsize(5) ysize(6) ///
title("L America") ytitle("NRA") xtitle("Land Gini") xlabel(0.6(0.05)0.9)
graph save landgini_int_lac, replace

*High Income Countries
xtreg nra_tott dict2 iplandgini landgini_dict2 inequality_1 urban lngdp aggdp arableland_pc agland foodindex ///
seventies eighties nineties noughties if region=="HIC"
est store landgini_int_hic

xtreg nra_tott i.dict2##c.iplandgini lngdp aggdp arableland_pc agland foodindex ///
seventies eighties nineties noughties if region=="HIC"
margins, at(iplandgini=(0.3(0.05)0.9) dict2=(0 1))
marginsplot, recastci(rline) plot1opts(lcolor(black) lwidth(medthin)) ci1opts(lwidth(thin) lcolor(black) lpattern(longdash))  ///
plot2opts(lcolor(gs5)) ci2opts(lwidth(thin) lcolor(gs5) lpattern(longdash)) ///
addplot(kdensity iplandgini if e(sample), yaxis(2) lwidth(vthin)) yline(0, lwidth(vthin)) graphregion(color(white)) xsize(5) ysize(6) ///
title("High Inc") ytitle("NRA") xtitle("Land Gini") xlabel(0.3(0.1)0.9)
graph save landgini_int_hic, replace

esttab landgini_1 landgini_2 landgini_int_africa landgini_int_asia landgini_int_lac landgini_int_hic using Landgini_Results.tex, ///
keep(iplandgini dict2 landgini_dict2 urban inequality_1 lngdp aggdp foodindex) ///
order(iplandgini dict2 landgini_dict2 urban inequality_1 lngdp aggdp foodindex) ///
replace b(2) se scalars("N_g Countries") sfmt(%12.0f) label nonumbers ///
mtitle("(5.1)" "(5.2)" "(5.3) Africa" "(5.4) Asia" "(5.5) LA" "(5.6) HIC") ///
compress nogaps addnotes("Models 5.1, 5.2 with country fixed effects" "All models include Arable land, Ag land, Food Index, Ag/GDP, Decade dummies")

esttab landgini_1 landgini_2 landgini_int_africa landgini_int_asia landgini_int_lac landgini_int_hic, ///
keep(iplandgini dict2 landgini_dict2 urban inequality_1 lngdp aggdp foodindex) ///
order(iplandgini dict2 landgini_dict2 urban inequality_1 lngdp aggdp foodindex) ///
replace b(2) se scalars("N_g Countries") sfmt(%12.0f) label nonumbers ///
mtitle("(5.1)" "(5.2)" "(5.3) Africa" "(5.4) Asia" "(5.5) LA" "(5.6) HIC") ///
compress nogaps addnotes("Models 5.1, 5.2 with country fixed effects" "All models include Arable land, Ag land, Food Index, Ag/GDP, Decade dummies")


grc1leg landgini_int_africa.gph landgini_int_asia.gph landgini_int_lac.gph landgini_int_hic.gph, graphregion(fcolor(white))
